﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.OleDb;
using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;

using lo = sqCore.sqLogger;

namespace sqCore
{
    /* Docs:
     * Summary
        * Base object for SqlA jobs types.
     * Variables
        * IsDone - If false, this job not runed.
        * ExecuteTime - Time that the job executed.
        * Result - The results of the execute.
     */
    [BsonKnownTypes(typeof(sqSqlQueryJob), typeof(sqMongoQueryJob<BsonDocument>))]
    public class sqJob
    {
        public bool IsDone;
        public DateTime ExecuteTime;
        public object Result;
        

        /* Docs:
        * Summary: Initialize the job.
        */
        public sqJob()
        {
            this.ExecuteTime = DateTime.Now;
            this.Result = new object();
            this.IsDone = false;

        }

        /* Docs:
        *Summary: Execute job and set results.
        */
        public virtual void executeJob()
        {
            this.IsDone = true;
            this.Result = true;
        }

        /* Docs:
        *Summary: Return results.
        */
        public virtual object getResult()
        {
            return this.Result;
        }

        /* Docs:
        *Summary: Return new instance that similar to this job befor execute.
        */
        public virtual sqJob renew()
        {
            return new sqJob();
        }

        /* Docs:
        *Summary: Return new instance that equles to this job before/after execute.
        */
        public virtual sqJob copy()
        {
            sqJob jobC = new sqJob();
            jobC.IsDone = this.IsDone;
            jobC.ExecuteTime = this.ExecuteTime;
            jobC.Result = this.Result;
            return jobC;
        }

    } //end of sqJob
}
